/*
*  RefCounted.h
*  
*
*  Created by Alexander Trutchenko on 11/02/12.
*  Copyright 2012 Free Team. All rights reserved.
*
*/

#ifndef __LL_RefCounted_h__
#define __LL_RefCounted_h__

#include "lid_lib/src/types/LLVector3D.h"

namespace lidlib {

////////////////////////////////////////////////////////
//
/** LLRefCounted
*  
*/
////////////////////////////////////////////////////////

class LLRefCounted
{
protected:
	// count of refrence
	unsigned int	_counter;
	
private:
	LLRefCounted(const LLRefCounted&);
	LLRefCounted& operator =(const LLRefCounted&);
public:
	LLRefCounted(): _counter(1) {;}
	virtual ~LLRefCounted() {;}
		//returns true if object is still exists (_counter > 0)
    virtual void increase(void)
	{
		++_counter;
	}
	virtual bool decrease(void)
	{
		--_counter;
		if (_counter == 0)
		{
			delete this;
			return false;
		}
		return true;
	}
	virtual unsigned int refCounter() const { return _counter; }
};

} // namespace lidlib

#endif //__LL_RefCounted_h__
